import store from '../store'

// 任务的状态
const taskState = {
	draft: '草稿',
	wait_prove: '待审核',
	prove_prove: '材料待验收',
	prove_done: '施工',
	done: '完成',
	reject: '关闭',
	cancel: '取消'
}
// 任务的状态2
const taskState2 = {
	draft: '待验收',
	pcheck: '验收通过',
	rcheck: '验收不通过'
}
// 项目状态
const projectState = {
	draft: '草稿',
	wait_prove: '待审核',
	scheme_formulation: '方案设计',
	project_offer: '项目报价',
	down_payment: '收取定金',
	contract: '合同签订',
	preparation: '施工准备',
	construction: '工程施工',
	project_check: '项目验收',
	cost_settle: '费用结算',
	done: '完成'
}

// 验收状态
const checkState = {
	draft: '待验收',
	pcheck: '通过',
	rcheck: '不通过'

}

// 验收类型
const checkType = {
	'0': '常规验收',
	'1': '整装验收',
	'2': '竣工验收'
}

// 结算状态
const accountType = {
	'draft': '草稿',
	'wait_prove': '待审核',
	'proved': '审核通过',
	'reject': '审核不通过',
}

// 商机状态
const commercialState = [{
		label: '商机',
		value: 1
	},
	{
		label: '潜在客户',
		value: 2
	},
	{
		label: '任务分配',
		value: 3
	},
	{
		label: '意向签约',
		value: 4
	},
	{
		label: '方案设计',
		value: 5
	},
	{
		label: '成功签单',
		value: 6
	}
]

// 装修情况
const decorateCondition = [{
		label: '精装',
		value: 'fitment01'
	},
	{
		label: '毛胚',
		value: 'fitment02'
	}
]

// 设计师数据
let designers = []
const getDesigners = function() {
	if (designers.length > 0) return
	uni.request({
		url: store.state.baseUrl + '/lwj/design_info',
		method: 'POST',
		header: {
			token: store.state.token
		},
		data: {},
		success: res => {
			if (res.data.code === 1) {
				res.data.data.list.map(item => {
					item.value = item.id
					item.label = item.designer
					delete item.id
					delete item.designer
					return item
				})
				designers = res.data.data.list
			}
		},
		fail: () => {},
		complete: () => {}
	});
}

// 业务员数据
let salesman = []
const getSalesman = function() {
	if (salesman.length > 0) return
	uni.request({
		url: store.state.baseUrl + '/lwj/saleman_info',
		method: 'POST',
		header: {
			token: store.state.token
		},
		data: {},
		success: res => {
			if (res.data.code === 1) {
				res.data.data.list.map(item => {
					item.value = item.id
					item.label = item.saleman
					delete item.id
					delete item.saleman
					return item
				})
				salesman = res.data.data.list
			}
		},
		fail: () => {},
		complete: () => {}
	});
}

// 楼盘数据
let buildings = []
const getBuildings = function(zone, search_key) {
	// if (buildings.length > 0) return
	uni.request({
		url: store.state.baseUrl + '/lwj/building_info',
		method: 'POST',
		header: {
			token: store.state.token
		},
		data: {
			zone: zone,
			search_key: search_key
		},
		success: res => {
			if (res.data.code === 1) {
				res.data.data.list.map(item => {
					item.value = item.id
					item.label = item.name
					delete item.id
					delete item.name
					return item
				})
				buildings = res.data.data.list
				return res.data.data.list
			}
		},
		fail: () => {},
		complete: () => {}
	});
}

//增/减项数据
const increaseArray = [{
		label: '增项',
		value: 'add'
	},
	{
		label: '减项',
		value: 'sub'
	}
]

//有无突发事件
const proruptionArray = [{
	label: '有',
	value: true
}, {
	label: '无',
	value: false
}]

//工种类型
const typeArray = [{
	label: '木工',
	value: '0'
}, {
	label: '电工',
	value: '1'
}, {
	label: '粉刷工',
	value: '2'
}, {
	label: '油漆工',
	value: '3'
}, {
	label: '瓦工',
	value: '4'
}, {
	label: '贴瓷砖工',
	value: '5'
}, {
	label: '泥工',
	value: '6'
}, {
	label: '搬运',
	value: '7'
}, {
	label: '水电工',
	value: '8'
}, {
	label: '其他',
	value: '9'
}]

//角色列表
const roleArray = [
	// 	{
	// 	label: '班主',
	// 	value: '0'
	// }, 
	{
		label: '工人',
		value: '1'
	}
]

//角色列表
const communicationArray = [{
		label: '电话',
		value: 'mobile'
	},
	{
		label: '微信',
		value: 'weixin'
	},
	{
		label: '面谈',
		value: 'interview'
	}
]

// 复尺类型
const measureType = {
	'door': '门',
	'shower_room': '淋浴房',
	'bathroom_cabinet': '浴室柜',
	'closestool': '马桶',
	'ambry':'橱柜',
	'wardrobe':'衣柜'
}


// 复尺类型选择数据
const measureTypechoise = [{
		label: '门',
		value: 'door'
	},
	{
		label: '淋浴房',
		value: 'shower_room'
	},
	{
		label: '浴室柜',
		value: 'bathroom_cabinet'
	},
	{
		label: '马桶',
		value: 'closestool'
	}
]

// 类型（门）
const doortype = [{
		label: '预留门边',
		value: 'double_chock',
	},
	{
		label: '单边直墙',
		value: 'unilateral',
	},
	{
		label: '双边直墙',
		value: 'bilateral'
	}

]
// 沐浴房类型
const showertype = [{
		label: 'L型',
		value: 'L'
	},
	{
		label: '圆弧型',
		value: 'C'
	},
	{
		label: '钻石型',
		value: 'D'
	},
	{
		label: '一字型',
		value: 'ONE'
	}
]
// 复尺状态
const checkruler = [{
		label: '待复尺',
		value: '1'
	},
	{
		label: '已复尺',
		value: '2'
	},
	{
		label: '复尺已审核',
		value: '3'
	},
	{
		label: '定制设计',
		value: '4'
	},
	{
		label: '设计已复核',
		value: '5'
	},
	{
		label: '定制已下单',
		value: '6'
	},
	{
		label: '已拆单',
		value: '7'
	},
	{
		label: '材料已到位',
		value: '8'
	},
	{
		label: '生产中',
		value: '9'
	},
	{
		label: '已包装',
		value: '10'
	},
	{
		label: '已装车',
		value: '11'
	},

]
getDesigners() // 获取设计师数据	
getSalesman() // 获取业务员数据
getBuildings() // 获取楼盘数据
export {
	taskState,
	taskState2,
	projectState,
	checkState,
	checkType,
	accountType,
	decorateCondition,
	commercialState,
	designers,
	salesman,
	buildings,
	increaseArray,
	proruptionArray,
	typeArray,
	roleArray,
	communicationArray,
	getBuildings,
	measureType,
	measureTypechoise,
	doortype,
	showertype,
	checkruler
}
